﻿@using OKRs.Models.ObjectiveViewModels
@model ObjectivesListViewModel

@{
    if (ViewData["Title"] == null)
    {
        ViewData["Title"] = "My Objectives";
    }

    Layout = "~/Views/Shared/_Layout.cshtml";
}
<ol class="breadcrumb">
    <li><a asp-controller="Home" asp-action="Index">Home</a></li>
    <li><a asp-controller="Objective" asp-action="All">All Objectives</a></li>
</ol>
<h3 class="clearfix">
    <span class="pull-left">@ViewData["Title"]</span>
    @if (Model.IsObjectivesForCurrentUser)
    {
        <a class="btn btn-sm btn-primary pull-right" asp-action="Create">
            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
            New Objective
        </a>
    }
    else
    {
        <a class="btn btn-sm btn-primary pull-right" asp-action="CreateForUser" asp-route-id="@Model.UserId">
            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
            New Objective
        </a>
    }
</h3>

<p>

</p>

@foreach (var objective in Model.Objectives)
{
    <div class="list-group">
        <div class="list-group-item active clearfix">
            <a class="pull-left list-group-item-heading" asp-action="Details" asp-route-id="@objective.Id">
                <strong>O: @objective.Title</strong>
            </a>
            <div class="btn-group pull-right">
                <a class="btn btn-xs btn-primary" asp-controller="KeyResult" asp-action="Add" asp-route-objectiveId="@objective.Id">
                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                    Add Key Result
                </a>
                <a class="btn btn-xs btn-primary" asp-action="Edit" asp-route-id="@objective.Id">
                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                    Edit
                </a>
            </div>
        </div>
        @foreach (var keyResult in objective.KeyResults)
        {
            <a asp-controller="KeyResult" asp-action="Details" asp-route-objectiveId="@objective.Id" asp-route-keyResultId="@keyResult.Id" class="list-group-item">K: @keyResult.Description</a>
        }
    </div>
}
